import { type PointFeature, ShapeTool } from './shape';

export class PointTool extends ShapeTool {
  addLabel = (
    id: string,
    coords: GeoJSON.Position[],
    _poss: GeoJSON.Position[] = [],
  ) => {
    const label = `${coords[0][0].toFixed(6)}, ${coords[0][1].toFixed(6)}`;
    this.createLabels(id, [label], coords, [0, -2]);
  };

  handleCreate = (feature: GeoJSON.Feature) => {
    const coords = (feature as PointFeature).geometry.coordinates;
    // 在顶点位置显示角度
    this.addLabel(feature.id as string, [coords], [coords]);

    this.draw?.setDrawingMode('simple_select');
  };

  handleDelete = (feature: GeoJSON.Feature) => this.delId(feature.id as string);
}
